package com.suqiu.qqrobot.config;

import com.suqiu.qqrobot.config.properties.BotProperties;
import com.suqiu.qqrobot.config.properties.BotProperty;
import com.suqiu.qqrobot.service.AiChatService;
import love.forte.simbot.message.ResourceImage;

public class AiSelector {

    private final BotProperties botProperties;
    private final AiChatService<String, String> openAiTurboModelService;
    private final AiChatService<String, String> openAiDavinciModelService;
    private final AiChatService<String, String> qingYuanModelService;
    private final AiChatService<String, ResourceImage> openAiImageModelService;


    public AiSelector(BotProperties botProperties, AiChatService<String, String> openAiDavinciModelService, AiChatService<String, String> openAiTurboModelService, AiChatService<String, String> qingYuanModelService, AiChatService<String, ResourceImage> openAiImageModelService) {
        this.botProperties = botProperties;
        this.openAiTurboModelService = openAiTurboModelService;
        this.openAiDavinciModelService = openAiDavinciModelService;
        this.qingYuanModelService = qingYuanModelService;
        this.openAiImageModelService = openAiImageModelService;
    }

    public AiChatService<?,?> select(String id) {
        BotProperty botProperty = botProperties.get(id);
        if (botProperty == null) {
            botProperties.put(id, new BotProperty());
        }
        switch (botProperties.get(id).getType()) {
            case QING_YUAN:
                return qingYuanModelService;
            case OPEN_AI_TURBO:
                return openAiTurboModelService;
            case OPEN_AI_DAVINCI:
                return openAiDavinciModelService;
            case OPEN_AI_IMAGE:
                return openAiImageModelService;
            default:
                throw new RuntimeException("未知的AI类型");
        }
    }
}
